//===----------------------------------------------------------------------===//
//
// This source file is part of the Soto for AWS open source project
//
// Copyright (c) 2017-2021 the Soto project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of Soto project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//

// THIS FILE IS AUTOMATICALLY GENERATED by https://github.com/soto-project/soto/tree/main/CodeGenerator. DO NOT EDIT.

import SotoCore

/// Error enum for TranscribeService
public struct TranscribeServiceErrorType: AWSErrorType {
    enum Code: String {
        case badRequestException = "BadRequestException"
        case conflictException = "ConflictException"
        case internalFailureException = "InternalFailureException"
        case limitExceededException = "LimitExceededException"
        case notFoundException = "NotFoundException"
    }

    private let error: Code
    public let context: AWSErrorContext?

    /// initialize TranscribeService
    public init?(errorCode: String, context: AWSErrorContext) {
        guard let error = Code(rawValue: errorCode) else { return nil }
        self.error = error
        self.context = context
    }

    internal init(_ error: Code) {
        self.error = error
        self.context = nil
    }

    /// return error code string
    public var errorCode: String { self.error.rawValue }

    /// Your request didn't pass one or more validation tests. For example, if the entity that you're trying to delete doesn't exist or if it is in a non-terminal state (for example, it's "in progress"). See the exception Message field for more information.
    public static var badRequestException: Self { .init(.badRequestException) }
    /// There is already a resource with that name.
    public static var conflictException: Self { .init(.conflictException) }
    /// There was an internal error. Check the error message and try your request again.
    public static var internalFailureException: Self { .init(.internalFailureException) }
    /// Either you have sent too many requests or your input file is too long. Wait before you resend your request, or use a smaller file and resend the request.
    public static var limitExceededException: Self { .init(.limitExceededException) }
    /// We can't find the requested resource. Check the name and try your request again.
    public static var notFoundException: Self { .init(.notFoundException) }
}

extension TranscribeServiceErrorType: Equatable {
    public static func == (lhs: TranscribeServiceErrorType, rhs: TranscribeServiceErrorType) -> Bool {
        lhs.error == rhs.error
    }
}

extension TranscribeServiceErrorType: CustomStringConvertible {
    public var description: String {
        return "\(self.error.rawValue): \(self.message ?? "")"
    }
}
